<template>
  <div class="gift">
    <Theme :theme="theme"></Theme>
    <div class="content">
      <van-nav-bar title="历史记录    >" to="" />
      <div class="content_top">
        <div id="nav_l" :class="{ current: currIdx == 0 }" @click="show(0)">
          全部
        </div>
        <div id="nav_r" :class="{ current: currIdx == 1 }" @click="show(1)">
          最热
        </div>
      </div>
      <ul class="content_down">
        <li v-for="card in list" :key="card.id">
          <img :src="card.goodsImg" alt="" />
          <p>{{ card.goodsName }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import Theme from "../../components/lsc/theme.vue";

export default {
  components: { Theme },

  created() {
    this.getlist();
  },
  methods: {
    show(index) {
      this.currIdx = index;
      this.getlist();
    },
    getlist() {
      axios({
        url: "/api/goods/findGoodsByTime",
        params: {
          typeId: this.types[this.currIdx],
        },
      }).then((res) => (this.list = res.data.data));
    },
  },
  data() {
    return {
      currIdx: 0,
      list: [],
      types: ["10000", "10001"],
      theme: "选择礼品卡",
    };
  },
};
</script>

<style scoped>
.gift {
  width: 100%;
  min-height: 6.4rem;
  background-color: #efeff4;
}
/deep/.van-nav-bar {
  background-color: #f5f5f5;
}
/deep/.van-nav-bar .van-icon {
  color: gray;
}
.content {
  width: 100%;
  padding-top: 0.43rem;
}
/deep/.van-nav-bar__content {
  font-size: 0.16rem;
}
.content /deep/.van-nav-bar__title {
  color: #666;
}
.content_top {
  width: 90%;
  margin: 0 auto;
  padding: 0.05rem;
  display: flex;
  border-radius: 0.3rem;
  justify-content: space-around;
  background-color: #6d86c4;
}
.content_top .current {
  background-color: #ffffff;
  color: #000 !important;
}
#nav_l,
#nav_r {
  width: 1.46rem;
  height: 0.4rem;
  line-height: 0.4rem;
  border-radius: 0.3rem;
  text-align: center;
  color: #fff;
}
.content_down {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}
.content_down li {
  width: 1.7rem;
  margin-top: 0.12rem;
  background-color: #fff;
}
.content_down li img {
  width: 100%;
  display: block;
}
.content_down li p {
  width: 100%;
  height: 0.4rem;
  line-height: 0.4rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>